/*
 * MIT License
 *
 * Copyright (c) 2024-2048 冰羽
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package cn.star.framework.excel.handler.settings;

import cn.star.framework.excel.core.Column;
import com.alibaba.excel.metadata.Head;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.ss.usermodel.Cell;

/**
 * 链接<br>
 *
 * @author zhaoweiping
 *     <p style='color: red'>Created on 2024-09-23 11:06:00
 * @since 3.0.0
 */
public class Link {

  @Getter @Setter private HyperlinkType type;

  /** 当{@link #type} 为 {@link HyperlinkType#DOCUMENT} 时，值为：sheet!cell，即sheet名称 + ！ + 单元格坐标 */
  @Getter @Setter private String address;

  /** 链接地址计算函数 */
  @Getter @Setter private AddressCalculate calculate;

  /** 将链接添加到那一列，即头所在行的某列 */
  @Getter @Setter private List<String> link;

  @FunctionalInterface
  public interface AddressCalculate {
    /**
     * 计算链接地址
     *
     * @param columns 上下文原始列集合
     * @param head 当前表头
     * @param cell 当前列
     * @param isHead 是否表头
     * @return
     */
    String calculate(List<Column> columns, Head head, Cell cell, boolean isHead);
  }
}
